<?php
namespace app\controllers;


use app\models\distribution\DistributionBasic;
use app\models\group\GroupFans;
use app\models\group\GroupList;
use app\models\marketing\MarketingGroup;
use app\models\marketing\MarketingGroupLevel;
use app\models\SetParam;
use app\models\user\User;
use app\models\user\UserAccount;
use app\models\user\UserCommission;
use app\models\user\UserLevel;
use app\models\user\X;
use app\services\Chain;
use app\util\Debug;
use yii\helpers\ArrayHelper;

class DemoController extends \app\controllers\Controller
{
    public function actionIndex()
    {
        $set = SetParam::getLastOne();

        // var_dump($set->vip5_count);

        $count = Chain::getChildrenAll(12191, [
            UserLevel::$keys['vip2'],
            UserLevel::$keys['vip3'],
            UserLevel::$keys['vip4'],
            UserLevel::$keys['vip5']
        ]);

        var_dump($set->vip2_ratio, $set->vip3_ratio);
    }


    // 身份
    public function actionLevel()
    {
        $x = X::find()
            ->where(['>', 'level', 1])
            ->all();

        foreach ($x as $i) {
            $u = User::findOne(['id' => $i->id]);
            if ($u->level > 1) {
                continue;
            }
            if ($u) {
                // var_dump($u->level, $i->level);exit;
                if ($i->level == 302) {
                    $u->level = 105;
                }
                if ($i->level == 301) {
                    $u->level = 104;
                }
                if ($i->level == 202) {
                    $u->level = 103;
                }
                if ($i->level == 201) {
                    $u->level = 102;
                }
                $u->save();
                echo $u->id, ' ', ' <br>';
            }
        }

        return 'ok';
        var_dump($x);
    }




}